<template>
	<view class="container">
		<view class="listText" @click="listText">
			<text>{{app.language.listText5}}</text>
		</view>
		<!-- 基本信息 -->
		<view v-if="currentStep === 0">
			<h2 class="title">{{ app.language.tbrInfo }}</h2>
			<view class="infoBox">
				<!-- 姓名 -->
				<view class="formItem1">
					<text>{{ app.language.name }}:</text>
					<view class="formB">
						{{form.name}}
					</view>
				</view>
				<!-- 公民身份证号 -->
				<view class="formItem1">
					<text>{{ app.language.card }}:</text>
					<view class="formB">
						{{form.card}}
					</view>
				</view>
				<!-- 联系电话 -->
				<view class="formItem1">
					<text>{{ app.language.phone }}:</text>
					<view class="formB">
						{{form.phone}}
					</view>
				</view>
			</view>
		</view>
		<view v-if="currentStep === 1">
			<!-- 娱乐场所基本信息 -->
			<view class="infoBox">
				<h2 class="title">{{app.language.yl_info}}</h2>
				<!-- 场所姓名 -->
				<view class="formItem1">
					<text><text class="bt">*</text>{{ app.language.yl_name }}:</text>
					<view class="formB">
						<input type="text" v-model="form.placeName" :placeholder="app.language.yl_Iname" />
					</view>
				</view>
				<!-- 场所地址 -->
				<view class="formItem1">
					<text><text class="bt">*</text>{{ app.language.yl_address }}:</text>
					<view class="formB">
						<input type="text" v-model="form.venueAddress" :placeholder="app.language.yl_Iaddress" />
					</view>
				</view>
				<!-- 经营性质 -->
				<view class="formItem1">
					<text><text class="bt">*</text>{{ app.language.yl_nature }}:</text>
					<view class="formB">
						<input type="text" v-model="form.businessNature" :placeholder="app.language.yl_Inature" />
					</view>
				</view>
				<!-- 派出所 -->
				<view class="formItem1">
					<text><text class="bt">*</text>{{ app.language.gxsldw }}:</text>
					<view class="formB">
						<picker mode="selector" name="pcs" :range="pcsList" @change="onpcsChange">
							<view class="picker">
								{{selectedpcsValue}}
							</view>
						</picker>
					</view>
				</view>
				<!-- 经营时间 -->
				<view class="formItem1">
					<text><text class="bt">*</text>{{ app.language.yl_time }}:</text>
					<view class="formB">
						<picker mode="date" :value="form.businessHours" :start="startDate" :end="endDate"
							@change="bindDateChange">
							<view class="uni-input">{{time}}</view>
						</picker>
					</view>
				</view>
				<!-- 经营状态 -->
				<view class="formItem1">
					<text><text class="bt">*</text>{{ app.language.yl_state }}:</text>
					<view class="formB">
						<radio-group @change="handleZtChange" class="radioGroup" v-model="form.businessStatus">
						  <label v-for="item in jyztoptions" :key="item.value">
						    <radio :value="item.value" :checked="form.businessStatus === item.value"/>
						    {{item.label}}
						  </label>
						</radio-group>
					</view>
				</view>
				<!-- 经营项目 -->
				<view class="formItem1">
					<text><text class="bt">*</text>{{ app.language.yl_project }}:</text>
					<view class="formC">
						<checkbox-group @change="handleChange">
							<label v-for="item in items" :key="item.value" class="checkboxYes">
								<checkbox :value="item.value" :checked="isSelected(item.value)"></checkbox>
								{{ item.name }}
							</label>
						</checkbox-group>
					</view>
				</view>
				<!-- 经营模式 -->
				<view class="formItem1">
					<text><text class="bt">*</text>{{ app.language.yl_mode }}:</text>
					<view class="formB">
						<radio-group @change="handleMs" class="radioGroup" v-model="form.managementModel">
						  <label v-for="item in jymsoptions" :key="item.value">
						    <radio :value="item.value" :checked="form.managementModel === item.value"/>
						    {{item.label}}
						  </label>
						</radio-group>
					</view>
				</view>
				<!-- 场所等级 -->
				<view class="formItem1">
					<text><text class="bt">*</text>{{ app.language.yl_csGrade }}:</text>
					<view class="formB">
						<radio-group @change="handleGrade" class="radioGroup" v-model="form.placeLevel">
						  <label v-for="item in csdjoptions" :key="item.value">
						    <radio :value="item.value" :checked="form.placeLevel === item.value"/>
						    {{item.label}}
						  </label>
						</radio-group>
					</view>
				</view>
				<!-- 营业执照号 -->
				<view class="formItem1">
					<text><text class="bt">*</text>{{ app.language.yl_tyxydm }}:</text>
					<view class="formB">
						<input type="text" v-model="form.businesslicensecode" :placeholder="app.language.yl_Ityxydm" />
					</view>
				</view>
				<!-- 营业执照上传 -->
				<view class="formItem">
					<text><text class="bt">*</text>{{ app.language.yl_yyImg }}:</text>
					<view class="hjbImg hjbImg1">
						<button type="default" @click="chooseImg(1)">{{ app.language.scimg }}</button>
					</view>
					<view class="scimageBox" v-if="yyImgList.length>0">
						<view class="del3" @click="delImg(yyImgList,1)">
							<image class="delImg" src="/static/dels.png"></image>
						</view>
						<image class="scimage" :src="apiUrl+item" v-for="(item,index) in yyImgList" :key='index'
							@click="previewImg(item)"></image>
					</view>
					<!-- <image class="scimage" :src="item" v-for="(item,index) in yyImgList" :key='index' @click="previewImg(item)"></image> -->
				</view>
				<!-- 文化许可证上传 -->
				<view class="formItem">
					<text>{{ app.language.yl_xkzImg }}:</text>
					<view class="hjbImg hjbImg1">
						<button type="default" @click="chooseImg(2)">{{ app.language.scimg }}</button>
					</view>
					<view class="scimageBox" v-if="xkzImgList.length>0">
						<view class="del3" @click="delImg(xkzImgList,2)">
							<image class="delImg" src="/static/dels.png"></image>
						</view>
						<image class="scimage" :src="apiUrl+item" v-for="(item,index) in xkzImgList" :key='index'
							@click="previewImg(item)"></image>
					</view>
					<!-- <image class="scimage" :src="item" v-for="(item,index) in xkzImgList" :key='index' @click="previewImg(item)"></image> -->
				</view>
				<!-- 房屋来源 -->
				<view class="formItem1">
					<text><text class="bt">*</text>{{ app.language.fwly }}:</text>
					<view class="formB">
						<radio-group @change="handleChangely" class="radioGroup" v-model="form.housesource">
						  <label v-for="item in fwlyoptions" :key="item.value">
						    <radio :value="item.value" :checked="form.housesource === item.value"/>
						    {{item.label}}
						  </label>
						</radio-group>
					</view>
				</view>
				<!-- 是否有合同 -->
				<view class="formItem1" v-if="ishousesource">
					<text>{{ app.language.hetong }}:</text>
					<view class="formB">
						<radio-group @change="handleChangeht" class="radioGroup" v-model="form.contract">
						  <label v-for="item in htongoptions" :key="item.value">
						    <radio :value="item.value" :checked="form.contract === item.value"/>
						    {{item.label}}
						  </label>
						</radio-group>
					</view>
				</view>
				<view class="formItem" v-if="ishetong">
					<text>{{ app.language.sclwimg }}:</text>
					<view class="hjbImg hjbImg1">
						<button type="default" @click="chooseImg(8)">{{ app.language.scimg }}</button>
					</view>
					<view class="scimageBox" v-if="fwhtImgList.length>0">
						<view class="del3" @click="delImg(fwhtImgList,8)">
							<image class="delImg" src="/static/dels.png"></image>
						</view>
						<image class="scimage" :src="apiUrl+item" v-for="(item,index) in fwhtImgList" :key='index'
							@click="previewImg(item)"></image>
					</view>
				</view>
			</view>
		</view>
		<view v-if="currentStep === 2">
			<h2 class="title">{{app.language.yl_csnInfo}}</h2>
			<view class="infoBox">
				<!-- 法人姓名 -->
				<view class="formItem1">
					<text><text class="bt">*</text>{{ app.language.ldy_legalPerson }}:</text>
					<view class="formB">
						<input type="text" v-model="form.legalPersonName"
							:placeholder="app.language.ldy_IlegalPerson" />
					</view>
				</view>
				<!-- 身份证号码 -->
				<view class="formItem1">
					<text><text class="bt">*</text>{{ app.language.ldy_card }}:</text>
					<view class="formB">
						<input type="text" v-model="form.idcard" :placeholder="app.language.ldy_Icard" />
					</view>
				</view>
				<!-- 性别 -->
				<view class="formItem1">
					<text><text class="bt">*</text>{{ app.language.gender }}:</text>
					<view class="formB">
						<picker mode="selector" name="gender" :range="genderList" @change="onChangeGender">
							<view class="picker">
								{{selectedGenderValue}}
							</view>
						</picker>
					</view>
				</view>
				<!-- 民族 -->
				<view class="formItem1">
					<text><text class="bt">*</text>{{ app.language.nation }}:</text>
					<view class="formB">
						<picker mode="selector" name="pcs" :range="list" @change="onChange">
							<view class="picker">
								{{selectedValue}}
							</view>
						</picker>
					</view>
				</view>
				<!-- 户籍所在地 -->
				<view class="formItem1">
					<view>
						<text><text class="bt">*</text>{{ app.language.ldy_minorDomicile }}:</text>
						<area-picker v-if="areaData.provinces.length > 0" :area-data="areaData"
							:default-area="defaultArea" @change="handleFirstAreaChange" />
					</view>
				</view>
				<!-- 联系电话 -->
				<view class="formItem1">
					<text><text class="bt">*</text>{{ app.language.phone }}:</text>
					<view class="formB">
						<input type="phone" v-model="form.phone1" :placeholder="app.language.Iphone" />
					</view>
				</view>
			</view>
		</view>
		<view v-if="currentStep === 3">
			<h2 class="title">{{ app.language.yl_cyryInfo }}</h2>
			<view class="infoBox">
				<view class="form" v-for="(item, index) in evpeopleList" :key="index">
					<image src="../../static/del.png" mode="" class="del" v-if="index>0" @click="handleDel(index)">
					</image>
					<!-- 姓名 -->
					<view class="formItem1">
						<text>{{ app.language.yl_cyryName }}:</text>
						<view class="formB">
							<input type="text" v-model="evpeopleList[index].name"
								:placeholder="app.language.yl_IcyryName" />
						</view>
					</view>
					<!-- 身份证号码 -->
					<view class="formItem1">
						<text>{{ app.language.ldy_card }}:</text>
						<view class="formB">
							<input type="text" v-model="evpeopleList[index].idcard"
								:placeholder="app.language.ldy_Icard" />
						</view>
					</view>
					<!-- 性别 -->
					<view class="formItem1">
						<text>{{ app.language.gender }}:</text>
						<view class="formB">
							<picker mode="selector" name="gender" :range="genderList"
								@change="onChangeCyryGender(index, $event)">
								<view class="picker">
									{{evpeopleList[index].agentvalue}}
								</view>
							</picker>
						</view>
					</view>
					<!-- 民族 -->
					<view class="formItem1">
						<text>{{ app.language.nation }}:</text>
						<view class="formB">
							<picker mode="selector" name="pcs" :range="list" @change="onChangeCyry(index, $event)">
								<view class="picker">
									{{evpeopleList[index].nationalityvalue}}
								</view>
							</picker>
						</view>
					</view>
					<!-- 户籍所在地 -->
					<view class="formItem1">
						<text>{{ app.language.ldy_minorDomicile }}:</text>
						<area-picker v-if="evpeopleList[index].areaData.provinces.length > 0"
							:area-data="evpeopleList[index].areaData" :default-area="evpeopleList[index].defaultArea1" @change="handletAreaChange(index, $event)" />
					</view>
					<!-- 联系电话 -->
					<view class="formItem1">
						<text>{{ app.language.phone }}:</text>
						<view class="formB">
							<input type="text" v-model="evpeopleList[index].contactNumber"
								:placeholder="app.language.Iphone" />
						</view>
					</view>
					<!-- 劳务合同 -->
					<view class="formItem">
						<text>{{ app.language.ldy_contract }}:</text>
						<view class="hjbImg hjbImg1">
							<button type="default" @click="chooseImg(3,index)">{{ app.language.scimg }}</button>
						</view>
						<view class="scimageBox" v-if="evpeopleList[index].xkzImgList.length>0">
							<view class="del3" @click="delImg(evpeopleList[index].xkzImgList,3)">
								<image class="delImg" src="/static/dels.png"></image>
							</view>
							<image class="scimage" :src="apiUrl+i" v-for="(i,index) in evpeopleList[index].xkzImgList"
								:key='index' @click="previewImg(item)"></image>
						</view>
						<!-- <image class="scimage" :src="item" v-for="(item,index) in lwhtImgList[index]" :key='index' @click="previewImg(item)"></image> -->
					</view>
				</view>
			</view>
			<!-- 新增从业人员 -->
			<view class="txry" @click="handleAdd">
				<view class="jia">
					<image src="../../static/jiahao.png" mode="" class="icon"></image>
					<text>{{app.language.addText}}</text>
				</view>
			</view>
		</view>
		<!-- 安全设备数量 -->
		<view v-if="currentStep === 4">
			<h2 class="title">{{ app.language.yl_csDeviceNum }}</h2>
			<view class="infoBox">
				<!-- 场所面积 -->
				<view class="formItem1">
					<text><text class="bt">*</text>{{ app.language.yl_area }}:</text>
					<view class="formB">
						<input type="text" v-model="form.venueArea" :placeholder="app.language.yl_Iarea" />
					</view>
				</view>
				<!-- 保安数量 -->
				<view class="formItem1">
					<text><text class="bt">*</text>{{ app.language.yl_baNum }}:</text>
					<view class="formB">
						<input type="text" v-model="form.securityGuardsNum" :placeholder="app.language.yl_IbaNum" />
					</view>
				</view>
				<!-- 监控储存时长 -->
				<view class="formItem1">
					<text><text class="bt">*</text>{{ app.language.yl_duration }}:</text>
					<view class="formB">
						<input type="text" v-model="form.monitorStorageDuration"
							:placeholder="app.language.yl_Iduration" />
					</view>
				</view>
				<!-- 消防通道数量 -->
				<view class="formItem1">
					<text><text class="bt">*</text>{{ app.language.yl_xfthoroug }}:</text>
					<view class="formB">
						<input type="text" v-model="form.fireExitsNum" :placeholder="app.language.yl_Ixfthoroug" />
					</view>
				</view>
				<!-- 监控数量 -->
				<view class="formItem">
					<text><text class="bt">*</text>{{ app.language.yl_jkNum }}:</text>
					<view class="hjbImg hjbImg1">
						<button type="default" @click="chooseImg(4)">{{ app.language.scimg }}</button>
					</view>
					<view class="scimageBox" v-if="jkList.length>0">
						<view class="del3" @click="delImg(jkList,4)">
							<image class="delImg" src="/static/dels.png"></image>
						</view>
						<image class="scimage" :src="apiUrl+i" v-for="(i,key) in jkList" :key='index'
							@click="previewImg(item)"></image>
					</view>
				</view>
				<!-- 防爆器材数量 -->
				<view class="formItem">
					<text><text class="bt">*</text>{{ app.language.ldy_fbqcNum }}:</text>
					<view class="hjbImg hjbImg1">
						<button type="default" @click="chooseImg(5)">{{ app.language.scimg }}</button>
					</view>
					<view class="scimageBox" v-if="fbqcList.length>0">
						<view class="del3" @click="delImg(fbqcList,5)">
							<image class="delImg" src="/static/dels.png"></image>
						</view>
						<image class="scimage" :src="apiUrl+i" v-for="(i,key) in fbqcList" :key='index'
							@click="previewImg(item)"></image>
					</view>
					<!-- <image class="scimage" :src="item" v-for="(item,index) in fbqcList" :key='index' @click="previewImg(item)"></image> -->
				</view>
				<!-- 消防设施 -->
				<view class="formItem">
					<text><text class="bt">*</text>{{ app.language.yl_xfss }}:</text>
					<view class="hjbImg hjbImg1">
						<button type="default" @click="chooseImg(6)">{{ app.language.scimg }}</button>
					</view>
					<view class="scimageBox" v-if="xfList.length>0">
						<view class="del3" @click="delImg(xfList,6)">
							<image class="delImg" src="/static/dels.png"></image>
						</view>
						<image class="scimage" :src="apiUrl+i" v-for="(i,key) in xfList" :key='index'
							@click="previewImg(item)"></image>
					</view>
					<!-- <image class="scimage" :src="item" v-for="(item,index) in xfList" :key='index' @click="previewImg(item)"></image> -->
				</view>
				<!-- 保安劳务合同 -->
				<view class="formItem">
					<text><text class="bt">*</text>{{ app.language.yl_baht }}:</text>
					<view class="hjbImg hjbImg1">
						<button type="default" @click="chooseImg(7)">{{ app.language.scimg }}</button>
					</view>
					<view class="scimageBox" v-if="bahtList.length>0">
						<view class="del3" @click="delImg(bahtList,7)">
							<image class="delImg" src="/static/dels.png"></image>
						</view>
						<image class="scimage" :src="apiUrl+i" v-for="(i,key) in bahtList" :key='index'
							@click="previewImg(item)"></image>
					</view>
					<!-- <image class="scimage" :src="item" v-for="(item,index) in bahtList" :key='index' @click="previewImg(item)"></image> -->
				</view>
			</view>
		</view>
		<view>
			<button v-if="currentStep > 0" @click="previousStep"
				class="previousStep">{{app.language.previousStep}}</button>
			<button v-if="currentStep < steps.length - 1" @click="nextStep"
				class="nextStep">{{app.language.nextStep}}</button>
				<!-- 提交 -->
			<button v-if="currentStep === steps.length - 1&&!isTB&&!isxg" @click="submitForm(0)"
				class="submitForm">{{app.language.tijiao}}</button>
				<!-- 修改 -->
				<button v-if="currentStep === steps.length - 1&&!isTB&&isxg" @click="submitForm(2)"
					class="submitForm">{{ app.language.djxg }}</button>
					<!-- 同步 -->
			<button v-if="currentStep === steps.length - 1&&isTB&&!isxg" @click="submitForm(1)"
				class="submitForm">{{ app.language.yjtb }}</button>
		</view>
		<!-- 是否同步的弹窗 -->
		<uni-popup ref="popup" type="bottom" border-radius="10px 10px 0 0" class="popup">
			<view class="popupBox">
				<view v-for="(item,index) in hotelBaseList" class="popupItem">
					<text>{{item.placeName}}</text>
					<button @click="handleTb(index)">{{app.language.yjtb}}</button>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import graceChecker from "../../components/graceChecker.js"
	import {
		Addylcs,xgylcs
	} from '@/api/form.js'
	import {
		getgetAppEntertainmentvenues
	} from '@/api/domicile.js'
	import config from '@/config.js';
	import {
		geAgent,
		getPcsList,
		getNationality,
		jgxmList
	} from '@/api/api.js'
	import {
		fetchAndProcessAreaData
	} from '@/api/processCountryData.js';
	import AreaPicker from '@/components/areapicker.vue';
	const global = getApp().globalData;
	export default {
		components: {
			AreaPicker
		},
		data() {
			return {
				apiUrl: config.baseUrl,
				rlsb: true,
				app: {
					global: global,
					name: global.appName,
					language: global.language
				},
				form: {
					name: "",
					card: "",
					phone: "",
				},
				currentStep: 0,
				steps: [{
						id: 0,
						title: '填表人信息'
					},
					{
						id: 1,
						title: '场所基本信息'
					},
					{
						id: 2,
						title: '场所内法人信息'
					},
					{
						id: 3,
						title: '场所内从业人员情况'
					},
					{
						id: 4,
						title: '场所内安全设备数量统计'
					},
				],
				// 民族
				list: [],
				mzlist: [],
				selectedValue: '',
				// 建筑性质
				jzlist: ['住宅性质', '商业性质', '办公性质', '工业性质'],
				selectedJzValue: "请选择",
				evpeopleList: [{
					name: "",
					idcard: "",
					agent: "",
					agentvalue: "",
					nationality: "",
					nationalityvalue: "",
					registeredResidence: "",
					registeredResidencevalue: "",
					contactNumber: "",
					serviceContract: "",
					xkzImgList: [],
					areaData: {
						provinces: [],
						cities: {},
						areas: {}
					},
					defaultArea1:""
				}],
				genderList: [],
				genderLists: [],
				selectedGenderValue: "",
				contractImg: [],
				time: '',
				items: [],
				selected: [], // 存储选中的值

				yyImgList: [], //营业执照图片
				xkzImgList: [], //文化许可证图片
				srcImg: [], //预览图片
				lwhtImgList: [], //劳务合同
				jkList: [], //监控数量
				fbqcList: [], //防爆器材数量
				xfList: [], //消防设施
				bahtList: [], //保安劳务合同
				token: "",
				selectedAddressValue: "",
				hjList: [],
				hjsList: [],
				pcsList: [],
				pcsLists: [],
				fwhtImgList:[],
				selectedpcsValue: "",
				userInfo: {},
				areaData: {
					provinces: [],
					cities: {},
					areas: {}
				},
				hotelBaseList: [],
				isTB: false,
				isxg: false,
				defaultArea: "",
				ishetong:false,
				 ishousesource:false,
				
				testValue: "1",
				jyztoptions: [
				  { value: "0", label: "" },
				  { value: "1", label: "" },
				  { value: "2", label: "" },
				  { value: "3", label: "" }
				],
				jymsoptions: [
				  { value: "0", label: "" },
				  { value: "1", label: "" },
				  { value: "2", label: "" }
				],
				csdjoptions: [
				  { value: "0", label: "A" },
				  { value: "1", label: "B" },
				  { value: "2", label: "C" },
				  { value: "3", label: "" }
				],
				fwlyoptions: [
				  { value: "0", label: "" },
				  { value: "1", label: "" },
				],
				htongoptions: [
				  { value: "0", label: "" },
				  { value: "1", label: "" }
				],
			};
		},
		computed: {
			startDate() {
				return this.getDate('start');
			},
			endDate() {
				return this.getDate('end');
			}
		},
		async onLoad(option) {
			uni.showLoading({
				title: this.app.language.jzz,
			});
			this.selectedValue = this.app.language.qxz
			this.agentvalue = this.app.language.qxz
			this.nationalityvalue = this.app.language.qxz
			this.egisteredResidencevalue = this.app.language.qxz
			this.selectedGenderValue = this.app.language.qxz
			this.time = this.app.language.qxz
			this.selectedAddressValue = this.app.language.qxz
			this.selectedpcsValue = this.app.language.qxz
			this.areaData = await fetchAndProcessAreaData();
			this.evpeopleList[0].areaData = await fetchAndProcessAreaData();
			this.evpeopleList[0].agentvalue = this.app.language.qxz
			this.evpeopleList[0].nationalityvalue = this.app.language.qxz
			this.jyztoptions[0].label = this.app.language.xiuye
			this.jyztoptions[1].label = this.app.language.yingye
			this.jyztoptions[2].label = this.app.language.zhuxiao
			this.jyztoptions[3].label = this.app.language.rcjk_other
			this.jymsoptions[0].label = this.app.language.chengbao
			this.jymsoptions[1].label = this.app.language.zizhu
			this.jymsoptions[2].label = this.app.language.hezuo
			this.csdjoptions[3].label = this.app.language.rcjk_other
			this.fwlyoptions[0].label = this.app.language.ziyou
			this.fwlyoptions[1].label = this.app.language.zl
			this.htongoptions[0].label = this.app.language.yes
			this.htongoptions[1].label = this.app.language.no
			this.getToken()
			this.getPcs()
			this.getMzList()
			this.getagent()
			this.getjyxm()
			// this.getList()
		},
		methods: {
			// 获取缓存
			getToken() {
				let that = this
				uni.getStorage({
					key: 'loginData',
					success: function(res) {
						that.form.reportType = res.data.userInfo.peopleType
						that.token = res.data.userInfo.appToken
						that.userInfo = res.data.userInfo
						that.form.phone = res.data.userInfo.phonenumber
						that.form.card = res.data.userInfo.idcard,
						that.form.name = res.data.userInfo.userName
						uni.hideLoading();
						that.getList(that.token)
					}
				});
			},
			// 获取初始数据
			getList(token){
				if(token){
					let data = {
						appToken: token,
						// uuid: this.userInfo.uuid
					}
					getgetAppEntertainmentvenues(data).then((res) => {
						if (res.code == 200&&res.data.length>0) {
							this.isTB = false
							this.isxg = true
							this.form = res.data[0]
							console.log('this.formthis.formthis.form',this.form)
							this.form.phone1 = this.form.phone
							this.form.phone = this.userInfo.phonenumber
							this.form.card = this.userInfo.idcard,
							this.form.name = this.userInfo.userName
							this.time = this.form.businessHours
							// this.form.businessProject = this.form.businessProject.split(',')
							this.selected = this.form.businessProject.split(',')
							this.yyImgList = this.form.businessLicense.split(',')
							this.xkzImgList = this.form.culturalLicense.split(',')
							
							this.jkList = this.form.monitorNum.split(',')
							this.fbqcList = this.form.equipmentNum.split(',')
							this.xfList = this.form.fpd.split(',')
							this.bahtList = this.form.serviceContract.split(',')
							this.selectedGenderValue = this.form.agent
							if(this.form.housesource=="0"){
								this.ishousesource=false
							}else{
								this.ishousesource=true
							}
							if(this.form.contract=="0"){
								this.ishetong=true
							}else{
								this.ishetong=false
							}
							if(this.form.contracimg){
								this.fwhtImgList = this.form.contracimg.split(',')
							}
							
							// 循环派出所遍历数据
							for (let i = 0; i < this.pcsLists.length; i++) {
								if (this.form.policeStation == this.pcsLists[i].deptId) {
									this.selectedpcsValue = this.pcsLists[i].deptName
								}
							}
							// 循环出租人民族遍历数据
							for (let i = 0; i < this.mzlist.length; i++) {
								if (this.form.nationality == this.mzlist[i].dictValue) {
									this.selectedValue = this.mzlist[i].dictLabel
								}
							}
							
							// 遍历出租人户籍所在地回显
							if(this.form.address){
								let address = this.form.address.split(' ')
								let provinceName = address[0]
								let cityName = address[1]
								let areaName = address[2]
								// 1. 查找省份
								let province = this.areaData.provinces.find(
									p => p.name === provinceName
								);
								if (!province) return;
								
								// 2. 查找城市
								let cities = this.areaData.cities[province.code] || [];
								let city = cities.find(
									c => c.name === cityName
								);
								if (!city) return;
								
								// 3. 查找区县
								let areas = this.areaData.areas[city.code] || [];
								let area = areas.find(
									a => a.name === areaName
								);
								if (!area) return;
								
								// 设置默认区域
								this.defaultArea = {
									province,
									city,
									area
								};
							}
							if(this.form.evpeopleList[0].name){
								this.evpeopleList = this.form.evpeopleList
								for (let a = 0; a < this.evpeopleList.length; a++) {
									// 性别
									for (let i = 0; i < this.genderLists.length; i++) {
										if (this.evpeopleList[a].agent == this.genderLists[i].dictValue) {
											this.evpeopleList[a].agentvalue = this.genderLists[i].dictLabel
										}else{
											this.evpeopleList[a].agentvalue = this.evpeopleList[a].agent
										}
									}
									// 民族
									for (let i = 0; i < this.mzlist.length; i++) {
										if (this.evpeopleList[a].nationality == this.mzlist[i].dictValue) {
											this.evpeopleList[a].nationalityvalue = this.mzlist[i].dictLabel
										}else{
											this.evpeopleList[a].nationalityvalue = this.evpeopleList[a].nationality
										}
									}
									// 劳务合同
									this.evpeopleList[a].xkzImgList = this.evpeopleList[a].serviceContract.split(',')
									// 户籍所在地回显
									this.evpeopleList[a].areaData = this.areaData
									if(this.evpeopleList[a].registeredResidence){
										let address1 = this.evpeopleList[a].registeredResidence.split(' ')
										let provinceName1 = address1[0]
										let cityName1 = address1[1]
										let areaName1 = address1[2]
										// 1. 查找省份
										let province1 = this.evpeopleList[a].areaData.provinces.find(
											p => p.name === provinceName1
										);
										if (!province1) return;
										
										// 2. 查找城市
										let cities1 = this.evpeopleList[a].areaData.cities[province1.code] || [];
										let city1 = cities1.find(
											c => c.name === cityName1
										);
										if (!city1) return;
										
										// 3. 查找区县
										let areas1 = this.evpeopleList[a].areaData.areas[city1.code] || [];
										let area1 = areas1.find(
											a => a.name === areaName1
										);
										if (!area1) return;
										
										// 设置默认区域
										this.evpeopleList[a].defaultArea1 = {
											province1,
											city1,
											area1
										};
									}
								}
							}
							uni.hideLoading();
						}
					
					})
				}else{
					uni.navigateTo({
						url: '../login/login',
					});
				}
			},

			nextStep() {
				console.log('currentStep111', this.currentStep)
				if (this.currentStep == 0) {
					if (this.currentStep < this.steps.length - 1) {
						this.currentStep++;
					}
					return
				}
				if (this.currentStep == 1) {
					if (!this.form.placeName) {
						uni.showToast({
							title: this.app.language.yl_Iname,
							icon: 'none',
						});
						return
					}
					if (!this.form.venueAddress) {
						uni.showToast({
							title: this.app.language.yl_Iaddress,
							icon: 'none',
						});
						return
					}
					if (!this.form.businessNature) {
						uni.showToast({
							title: this.app.language.yl_Inature,
							icon: 'none',
						});
						return
					}
					if (!this.selectedpcsValue || this.selectedpcsValue === this.app.language.qxz) {
						uni.showToast({
							title: this.app.language.hjpcsTx,
							icon: 'none',
						});
						return
					}
					if (!this.form.businessHours) {
						uni.showToast({
							title: this.app.language.yl_Itime,
							icon: 'none',
						});
						return
					}
					if (!this.form.businessStatus) {
						uni.showToast({
							title: this.app.language.yl_istate,
							icon: 'none',
						});
						return
					}
					if (!this.form.businessProject) {
						uni.showToast({
							title: this.app.language.yl_iproject,
							icon: 'none',
						});
						return
					}
					if (!this.form.managementModel) {
						uni.showToast({
							title: this.app.language.yl_imode,
							icon: 'none',
						});
						return
					}
					if (!this.form.placeLevel) {
						uni.showToast({
							title: this.app.language.yl_icsGrade,
							icon: 'none',
						});
						return
					}
					if (this.yyImgList.length == 0) {
						uni.showToast({
							title: this.app.language.yl_iyyImg,
							icon: 'none',
						});
						return
					}
					if (!this.form.housesource) {
						uni.showToast({
							title: this.app.language.yl_iyyImg,
							icon: 'none',
						});
						return
					}
					// if (this.xkzImgList.length == 0) {
					// 	uni.showToast({
					// 		title: this.app.language.yl_ixkzImg,
					// 		icon: 'none',
					// 	});
					// 	return
					// }
					// return
					// 调用娱乐场所列表
					let data = {
						businesslicensecode: this.form.businesslicensecode
					}
					if (!this.isTB&&!this.isxg) {
						getgetAppEntertainmentvenues(data).then((res) => {
							console.log('resresres', res)
							if (res.data.length > 0) {
								this.hotelBaseList = res.data
								this.$refs.popup.open('center')
							} else {
								if (this.currentStep < this.steps.length - 1) {
									this.currentStep++;
								}
								return
							}
							// if (this.currentStep < this.steps.length - 1) {
							// 	this.currentStep++;
							// }
							// if (res.code == 200) {
							// 	uni.hideLoading();
							// 	uni.showToast({
							// 		title: this.app.language.qddsh,
							// 		icon: 'success',
							// 	});
							// 	setTimeout(() => {
							// 		console.log('跳转首页')
							// 		uni.reLaunch({
							// 			url: '/pages/enter/listText'
							// 		});
							// 	}, 1000);
							// }
						})
					} else {
						if (this.currentStep < this.steps.length - 1) {
							this.currentStep++;
						}
						return
					}
				}
				if (this.currentStep == 2) {
					if (!this.form.legalPersonName) {
						uni.showToast({
							title: this.app.language.ldy_IlegalPerson,
							icon: 'none',
						});
						return
					}
					if (!this.form.idcard) {
						uni.showToast({
							title: this.app.language.Icard,
							icon: 'none',
						});
						return
					}
					if (!this.selectedGenderValue || this.selectedGenderValue === this.app.language.qxz) {
						uni.showToast({
							title: this.app.language.Igender,
							icon: 'none',
						});
						return
					}
					if (!this.selectedValue || this.selectedValue === this.app.language.qxz) {
						uni.showToast({
							title: this.app.language.ination,
							icon: 'none',
						});
						return
					}
					if (!this.selectedAddressValue || this.selectedAddressValue === this.app.language.qxz) {
						uni.showToast({
							title: this.app.language.ldy_IminorDomicile,
							icon: 'none',
						});
						return
					}
					if (!this.form.phone1) {
						uni.showToast({
							title: this.app.language.Iphone,
							icon: 'none',
						});
						return
					}
					if (this.currentStep < this.steps.length - 1) {
						this.currentStep++;
					}
					return
				}
				if (this.currentStep == 3) {
					// for (let i = 0; i < this.evpeopleList.length; i++) {
					// 	if (!this.evpeopleList[i].name) {
					// 		uni.showToast({
					// 			title: this.app.language.iczrName,
					// 			icon: 'none',
					// 		});
					// 		return
					// 	}
					// 	if (!this.evpeopleList[i].idcard) {
					// 		uni.showToast({
					// 			title: this.app.language.ldy_Icard,
					// 			icon: 'none',
					// 		});
					// 		return
					// 	}
					// 	if (!this.evpeopleList[i].agentvalue || this.evpeopleList[i].agentvalue === this.app.language
					// 		.qxz) {
					// 		uni.showToast({
					// 			title: this.app.language.Igender,
					// 			icon: 'none',
					// 		});
					// 		return
					// 	}
					// 	if (!this.evpeopleList[i].nationalityvalue || this.evpeopleList[i].nationalityvalue === this.app
					// 		.language.qxz) {
					// 		uni.showToast({
					// 			title: this.app.language.ination,
					// 			icon: 'none',
					// 		});
					// 		return
					// 	}
					// 	if (!this.evpeopleList[i].registeredResidencevalue || this.evpeopleList[i]
					// 		.registeredResidencevalue === this.app.language.qxz) {
					// 		uni.showToast({
					// 			title: this.app.language.ldy_IminorDomicile,
					// 			icon: 'none',
					// 		});
					// 		return
					// 	}
					// 	if (!this.evpeopleList[i].contactNumber) {
					// 		uni.showToast({
					// 			title: this.app.language.Iphone,
					// 			icon: 'none',
					// 		});
					// 		return
					// 	}
					// 	if (this.evpeopleList[i].xkzImgList.length == 0) {
					// 		uni.showToast({
					// 			title: this.app.language.ldy_icontract,
					// 			icon: 'none',
					// 		});
					// 		return
					// 	}
						
					// }
					if (this.currentStep < this.steps.length - 1) {
						this.currentStep++;
					}
					return
				}
			},
			previousStep() {
				if (this.currentStep > 0) {
					this.currentStep--;
				}
			},

			// 获取性别列表
			getagent() {
				geAgent().then((res) => {
					this.genderLists = res.rows
					console.log('2222222',this.genderLists)
					for (let i = 0; i < res.rows.length; i++) {
						this.genderList.push(res.rows[i].dictLabel);
					}
				})
			},
			
			// 经营项目
			getjyxm() {
				jgxmList().then((res) =>{
					console.log('经营项目',res)
					// this.genderLists = res.rows
					for (let i = 0; i < res.rows.length; i++) {
						let temp = {
							name:res.rows[i].dictLabel,
							value:res.rows[i].dictValue
						}
						this.items.push(temp);
					}
				})
			},

			// 获取名族列表
			getMzList() {
				getNationality().then((res) => {
					this.mzlist = res.rows
					for (let i = 0; i < res.rows.length; i++) {
						this.list.push(res.rows[i].dictLabel);
					}
				})
			},

			/// 获取派出所列表
			getPcs() {
				let data = {
					"": ""
				}
				getPcsList(data).then((res) => {
					this.pcsLists = res.data
					console.log('res.data', res.data)
					if (res.code == 200) {
						for (let i = 0; i < res.data.length; i++) {
							this.pcsList.push(res.data[i].deptName);
						}
					}
				})
			},
			// 房屋来源
			handleChangely(e) {
				this.form.housesource = e.detail.value;
				console.log('this.form.housesource',this.form.housesource)
				if (this.form.housesource == 1) {
					this.ishousesource = true
				} else if (this.form.housesource == 0) {
					this.ishousesource = false
				}
			},
			
			// 是否有合同
			handleChangeht(e) {
				this.form.contract = e.detail.value;
				console.log('this.form.contract',this.form.contract)
				if (this.form.contract == 0) {
					this.ishetong = true
				} else if (this.form.contract == 1) {
					this.ishetong = false
				}
			},

			listText() {
				if (this.token) {
					if (this.userInfo.peopleType == "people") {
						if (!this.userInfo.userName && !this.userInfo.idcard &&
							!this.userInfo.idcardFront && !this.userInfo.idcardBack) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						} else {
							uni.reLaunch({
								url: '/pages/enter/listText'
							});
						}
					} else if (this.userInfo.peopleType == "police") {
						if (!this.userInfo.agent && !this.userInfo.birthdate && !this.userInfo.birthdate && !this
							.userInfo
							.nationality && !this.userInfo.policeNumber &&
							!this.userInfo.personnelCategory && !this.userInfo.department && !this.userInfo.workTime &&
							!
							this.userInfo.positionRank &&
							!this.userInfo.marriage && !this.userInfo.height && !this.userInfo.weight && !this.userInfo
							.photo) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						} else {
							uni.reLaunch({
								url: '/pages/enter/listText'
							});
						}
					}
				} else {
					uni.navigateTo({
						url: '../login/login',
					});
				}
			},

			// // 地址1
			// onChangeaddresshj (index,e){
			// 	// this.selectedAddressValue = this.hjList[e.detail.value];
			// 	// this.form.address = this.hjsList[e.detail.value].domicileId;
			// 	this.evpeopleList[index].registeredResidencevalue = this.hjList[e.detail.value];
			// 	this.evpeopleList[index].registeredResidence = this.hjsList[e.detail.value].domicileId;
			// },
			async loadAreaData() {
				uni.showLoading({
					title: this.app.language.jzz
				});

				try {
					const data = await fetchAndProcessAreaData();
					if (data) {
						this.areaData = data;
					}
					// else {
					// 	uni.showToast({
					// 		title: '加载地区数据失败',
					// 		icon: 'none'
					// 	});
					// }
				} catch (error) {
					console.error('加载地区数据出错:', error);
					// uni.showToast({
					// 	title: '加载地区数据出错',
					// 	icon: 'none'
					// });
				} finally {
					uni.hideLoading();
				}
			},
			// 三级联动
			handleFirstAreaChange(selected) {
				// this.firstSelectedArea = selected;
				console.log('第一个选择器选择:', selected);
				this.selectedAddressValue = selected.fullText
				this.form.address = selected.fullText
			},

			async loadAreaData1() {
				uni.showLoading({
					title: this.app.language.jzz
				});

				try {
					const data = await fetchAndProcessAreaData();
					if (data) {
						for (let i = 0; i < this.evpeopleList.length; i++) {
							this.evpeopleList[i].areaData = data;
						}
					}
					// else {
					// 	uni.showToast({
					// 		title: '加载地区数据失败',
					// 		icon: 'none'
					// 	});
					// }
				} catch (error) {
					console.error('加载地区数据出错:', error);
					// uni.showToast({
					// 	title: '加载地区数据出错',
					// 	icon: 'none'
					// });
				} finally {
					uni.hideLoading();
				}
			},
			// 三级联动-未成年
			handletAreaChange(index, selected) {
				// this.firstSelectedArea = selected;
				console.log('第二个选择器选择:', selected);
				this.evpeopleList[index].registeredResidencevalue = selected.fullText
				this.evpeopleList[index].registeredResidence = selected.fullText
				console.log('this.evpeopleList', this.evpeopleList)
			},

			// 场所内法人信息--选择性别
			onChangeGender(e) {
				this.selectedGenderValue = this.genderList[e.detail.value];
				this.form.agent = this.genderLists[e.detail.value].dictValue;
			},

			// 场所内法人信息--选择民族
			onChange(e) {
				this.selectedValue = this.list[e.detail.value];
				this.form.nationality = this.mzlist[e.detail.value].dictValue;
			},

			// 场所内法人信息--户籍
			// onChangeaddress(e) {
			// 	this.selectedAddressValue = this.hjList[e.detail.value];
			// 	this.form.address = this.hjsList[e.detail.value].domicileId;
			// },

			// 场所从业人员情况--选择性别
			onChangeCyryGender(index, e) {
				this.evpeopleList[index].agentvalue = this.genderList[e.detail.value];
				this.evpeopleList[index].agent = this.genderLists[e.detail.value].dictValue;
			},

			// 场所内从业人员情况--选择民族
			onChangeCyry(index, e) {
				this.evpeopleList[index].nationalityvalue = this.list[e.detail.value];
				this.evpeopleList[index].nationality = this.mzlist[e.detail.value].dictValue;
			},

			// 选择管辖派出所
			onpcsChange(e) {
				this.selectedpcsValue = this.pcsList[e.detail.value];
				this.form.policeStation = this.pcsLists[e.detail.value].deptId;
			},

			// 上传
			chooseImg(item, index) {
				uni.chooseImage({
					//同时选中的图片的数量
					count: 5,
					//图片的格式  原图  压缩
					sizeType: ['original', 'compressed'],
					//图片的来源  相册  照相机
					sourceType: ['album', 'camera'],
					success: (result) => {
						this.srcImg = result.tempFilePaths
						let tempFilePaths = result.tempFilePaths;
						// this.tempFilePathList = result.tempFilePaths;
						let base64List = this.form.chooseImags;
						// 图片路径转换成base64格式
						tempFilePaths.forEach((item, index) => {
							uni.getFileSystemManager().readFile({
								filePath: item, // 图片文件路径
								encoding: 'base64', // 编码格式为base64
								success: res => { // 成功回调
									let base64 = 'data:image/jpeg;base64,' + res
										.data; // 拼接data URI
									base64List.push(base64);
									if (base64List.length === tempFilePaths.length) {
										this.form.chooseImags = base64List;
									}
								},
								fail: err => {
									console.error('读取文件失败', err);
								}
							});
						});

						// 上传图片并返回路径
						let imgList = [];
						uni.showLoading({
							title: this.app.language.jzz,
						});
						tempFilePaths.forEach((tempFilePaths) => {
							const uploadTask = uni.uploadFile({
								url: 'https://mqzhian.cn:8088/common/upload', // 你的ThinkPHP服务器地址
								filePath: tempFilePaths,
								name: 'file', // 这里根据服务器接收的字段来定义
								success: (uploadFileRes) => {
									const data = JSON.parse(uploadFileRes.data);
									console.log('上传成功', data);
									uni.hideLoading();
									// 这里处理返回的图片路径，例如保存到数组中
									imgList.push(data.fileName);
									console.log('indexindexindex', index)
									if (item == 1) {
										this.yyImgList = imgList
										this.form.businessLicense = imgList.join(',')
									} else if (item == 2) {
										this.xkzImgList = imgList
										this.form.culturalLicense = imgList.join(',')
									} else if (item == 3) {
										this.evpeopleList[index].xkzImgList = imgList
										this.evpeopleList[index].serviceContract = imgList
											.join(',')
									} else if (item == 4) {
										this.jkList = imgList
										this.form.monitorNum = imgList.join(',')
									} else if (item == 5) {
										this.fbqcList = imgList
										this.form.equipmentNum = imgList.join(',')
									} else if (item == 6) {
										this.xfList = imgList
										this.form.fpd = imgList.join(',')
									} else if (item == 7) {
										this.bahtList = imgList
										this.form.serviceContract = imgList.join(',')
									}else if (item == 8) {
										this.fwhtImgList = imgList
										this.form.contracimg = imgList.join(',')
									}
								},
								fail: (error) => {
									console.error('上传失败', error);
									uni.showToast({
										title: this.app.language.scerror,
										icon: 'none',
									});
								}
							});
						});
					},
				});
			},

			//  form表单+1
			handleAdd() {
				let prem = {
					name: "",
					idcard: "",
					agent: this.app.language.qxz,
					nationality: this.app.language.qxz,
					registeredResidence: "",
					contactNumber: "",
					serviceContract: "",
					xkzImgList: [],
					areaData: {
						provinces: [],
						cities: {},
						areas: {}
					},
					defaultArea1:""
				}
				this.evpeopleList.push(prem); // 添加一个新的空表单项
				console.log('this.evpeopleListthis.evpeopleList', this.evpeopleList)
				this.loadAreaData1()
			},

			// 预览图片
			previewImg(current) {
				uni.previewImage({
					current,
					urls: this.srcImg,
					// 图片指示器样式: 小圆点
					indicator: 'default',
					// 循环预览
					loop: true
				})
			},

			// 删除图片
			delImg(index, id) {
				console.log('id', id)
				uni.showModal({
					title: this.app.language.titDel, // 弹框标题
					content: this.app.language.delBtn, // 弹框内容
					cancelText: this.app.language.popCancelText, // 取消按钮文本
					confirmText: this.app.language.okBtn, // 确认按钮文本
					success: (res) => {
						if (res.confirm) {
							// 用户点击了“确定”按钮
							if (id == 1) {
								this.yyImgList = []
							} else if (id == 2) {
								this.xkzImgList = []
							} else if (id == 3) {
								for (let i = 0; i < this.evpeopleList.length; i++) {
									this.evpeopleList[i].xkzImgList = []
									this.evpeopleList[i].serviceContract = ""
								}
							} else if (id == 4) {
								this.jkList = []
							} else if (id == 5) {
								this.fbqcList = []
							} else if (id == 6) {
								this.xfList = []
							} else if (id == 7) {
								this.bahtList = []
							}
						} else if (res.cancel) {
							// 用户点击了“取消”按钮，或者关闭了弹框
							console.log('用户取消删除');
						}
					}
				});
			},

			// form表单-1
			handleDel(index) {
				let that = this
				// uni.showModal({
				// 	// title: '提示',
				// 	content: '确定要删除吗?',
				// 	success: function(res) {
				// 		if (res.confirm) {

				// 			// 用户点击了确定按钮的相关逻辑可以放在这里
				// 		} else if (res.cancel) {
				// 			console.log('用户点击取消');
				// 			// 用户点击了取消按钮的相关逻辑可以放在这里
				// 		}
				// 	}
				// });
				that.evpeopleList.splice(index, 1); // 移除指定索引的表单项
			},

			getDate(type) {
				console.log('222222', type)
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();

				if (type === 'start') {
					year = year - 60;
				} else if (type === 'end') {
					year = year + 2;
				}
				month = month > 9 ? month : '0' + month;
				day = day > 9 ? day : '0' + day;
				return `${year}-${month}-${day}`;
			},

			// 经营状态
			handleZtChange(e) {
				this.form.businessStatus = e.detail.value
			},

			// 经营项目多选
			handleChange(e) {
				this.form.businessProject = e.detail.value.join(',');
			},
			isSelected(value) {
				return this.selected.includes(value);
			},

			// 经营模式
			handleMs(e) {
				this.form.managementModel = e.detail.value
			},

			// 场所等级
			handleGrade(e) {
				this.form.placeLevel = e.detail.value
			},

			// 经营时间选择
			bindDateChange(e) {
				this.time = e.detail.value
				this.form.businessHours = e.detail.value
			},

			handleTb(index) {
				this.form = this.hotelBaseList[index]
				console.log('this.form',this.form);
				this.evpeopleList = JSON.parse(JSON.stringify(this.hotelBaseList[index].evpeopleList));
				this.selected = this.form.businessProject.split(',')
				// 派出所
				for (let i = 0; i < this.pcsLists.length; i++) {
					if (this.form.policeStation == this.pcsLists[i].deptId) {
						this.selectedpcsValue = this.pcsLists[i].deptName
					}
				}
				// 时间
				this.time = this.form.businessHours
				// 营业执照
				if (this.form.businessLicense) {
					this.yyImgList = this.form.businessLicense.split(',')
				} else {
					this.yyImgList = []
				}
				// 文化许可证
				if (this.form.culturalLicense) {
					this.xkzImgList = this.form.culturalLicense.split(',')
				} else {
					this.xkzImgList = []
				}
				if(this.form.housesource=="0"){					this.ishousesource=false				}else{					this.ishousesource=true				}				if(this.form.contract=="0"){					this.ishetong=true				}else{					this.ishetong=false				}				if(this.form.contracimg){					this.fwhtImgList = this.form.contracimg.split(',')				}

				// 场所内法人信息
				// 性别
				this.selectedGenderValue = this.form.agent
				// 民族
				for (let i = 0; i < this.mzlist.length; i++) {
					if (this.form.nationality == this.mzlist[i].dictValue) {
						this.selectedValue = this.mzlist[i].dictLabel
					}
				}

				// 户籍所在地
				let areaValue = this.convertAreaCode(this.form.address)
				// 户籍地回显
				let provinceName = areaValue[0]
				let cityName = areaValue[1]
				let areaName = areaValue[2]
				// 1. 查找省份
				let province = this.areaData.provinces.find(
					p => p.code === provinceName
				);
				if (!province) return;

				// 2. 查找城市
				let cities = this.areaData.cities[province.code] || [];
				let city = cities.find(
					c => c.code === cityName
				);
				if (!city) return;

				// 3. 查找区县
				let areas = this.areaData.areas[city.code] || [];
				let area = areas.find(
					a => a.code === areaName
				);
				if (!area) return;
				// 设置默认区域
				this.defaultArea = {
					province,
					city,
					area
				};

				// 从业人员
				console.log('this.evpeopleList1',this.evpeopleList)
				if (this.evpeopleList) {
					this.evpeopleList = this.form.evpeopleList
					for (let j = 0; j < this.evpeopleList.length; j++) {
						// 性别
						this.evpeopleList[j].agentvalue = this.evpeopleList[j].agent
						this.evpeopleList[j].nationalityvalue = this.evpeopleList[j].nationality
						// for (let i = 0; i < this.genderLists.length; i++) {
						// 	if (this.evpeopleList[j].agent === this.genderLists[i].dictValue) {
						// 		this.evpeopleList[j].agentvalue = this.genderLists[i].dictLabel
						// 	}
						// }
						// 民族
						for (let i = 0; i < this.mzlist.length; i++) {
							if (this.evpeopleList[j].nationality === this.mzlist[i].dictValue) {
								this.evpeopleList[j].nationalityvalue = this.mzlist[i].dictLabel
							}
						}
						// 户籍地
						this.evpeopleList[j].defaultArea1 = {
							province:"",
							city:"",
							area:""
						}
						this.evpeopleList[j].areaValue = this.convertAreaCode(this.evpeopleList[j].registeredResidence)
						// 户籍地回显
						this.evpeopleList[j].provinceName = this.evpeopleList[j].areaValue[0]
						this.evpeopleList[j].cityName = this.evpeopleList[j].areaValue[1]
						this.evpeopleList[j].areaName = this.evpeopleList[j].areaValue[2]
						// 1. 查找省份
						this.evpeopleList[j].province = this.areaData.provinces.find(
							p => p.code === this.evpeopleList[j].provinceName
						);
						
						if (!province) return;

						// 2. 查找城市
						this.evpeopleList[j].cities = this.areaData.cities[this.evpeopleList[j].province.code] || [];
						this.evpeopleList[j].city = this.evpeopleList[j].cities.find(
							c => c.code === this.evpeopleList[j].cityName
						);
						if (!city) return;

						// 3. 查找区县
						this.evpeopleList[j].areas = this.areaData.areas[this.evpeopleList[j].city.code] || [];
						this.evpeopleList[j].area = this.evpeopleList[j].areas.find(
							a => a.code === this.evpeopleList[j].areaName
						);
						console.log('this.evpeopleList',this.evpeopleList)
						if (!area) return;
						this.evpeopleList[j].areaData = this.areaData;
						// 设置默认区域
						this.evpeopleList[j].defaultArea1.province = this.evpeopleList[j].province
						this.evpeopleList[j].defaultArea1.city = this.evpeopleList[j].city
						this.evpeopleList[j].defaultArea1.area = this.evpeopleList[j].area
						
						// 劳务合同
						if(this.evpeopleList[j].serviceContract){
							this.evpeopleList[j].xkzImgList = this.evpeopleList[j].serviceContract.split(',')
						}else{
							this.evpeopleList[j].xkzImgList = []
						}
						
					}
					// debugger
				}

				// 电话
				this.form.phone1 = this.form.phone
				// 监控数量
				if(this.form.monitorNum){
					this.jkList = this.form.monitorNum.split(',')
				}else{
					this.jkList = []
				}
				
				// 防爆器材数量
				if(this.form.equipmentNum){
					this.fbqcList = this.form.equipmentNum.split(',')
				}else{
					this.fbqcList = []
				}
				// 消防设施
				if(this.form.fpd){
					this.xfList = this.form.fpd.split(',')
				}else{
					this.xfList = []
				}
				// 保安劳务合同
				if(this.form.serviceContract){
					this.bahtList = this.form.serviceContract.split(',')
				}else{
					this.bahtList = []
				}

				this.isTB = true
				this.isxg = false
				this.$refs.popup.close()
			},

			// 转换
			// 更完整的转换函数
			convertAreaCode(shortCodes) {
				if (!shortCodes) return ['', '', ''];

				const codes = shortCodes.split(',');
				const result = ['', '', ''];

				// 省级
				if (codes[0]) {
					result[0] = codes[0].padEnd(6, '0');
				}

				// 市级
				if (codes[1]) {
					if (codes[1].length === 4) {
						result[1] = codes[1].padEnd(6, '0');
					} else if (codes[1].length === 2) {
						result[1] = result[0].substring(0, 2) + codes[1].padEnd(4, '0');
					} else {
						result[1] = codes[1];
					}
				} else {
					result[1] = result[0];
				}

				// 区级
				if (codes[2]) {
					if (codes[2].length === 6) {
						result[2] = codes[2];
					} else if (codes[2].length === 4) {
						result[2] = result[0].substring(0, 2) + codes[2];
					} else if (codes[2].length === 2) {
						result[2] = result[1].substring(0, 4) + codes[2];
					}
				} else {
					result[2] = result[1];
				}

				return result;
			},

			submitForm(val) {
				if (this.currentStep == 4) {
					if (!this.form.venueArea) {
						uni.showToast({
							title: this.app.language.yl_Iarea,
							icon: 'none',
						});
						return
					}
					if (!this.form.securityGuardsNum) {
						uni.showToast({
							title: this.app.language.yl_IbaNum,
							icon: 'none',
						});
						return
					}
					if (!this.form.monitorStorageDuration) {
						uni.showToast({
							title: this.app.language.yl_Iduration,
							icon: 'none',
						});
						return
					}
					if (!this.form.fireExitsNum) {
						uni.showToast({
							title: this.app.language.yl_Ixfthoroug,
							icon: 'none',
						});
						return
					}
					if (!this.form.fireExitsNum) {
						uni.showToast({
							title: this.app.language.yl_Ixfthoroug,
							icon: 'none',
						});
						return
					}
					if (this.jkList.length == 0) {
						uni.showToast({
							title: this.app.language.fw_imonitorNum,
							icon: 'none',
						});
						return
					}
					if (this.fbqcList.length == 0) {
						uni.showToast({
							title: this.app.language.ldy_fbqcNum,
							icon: 'none',
						});
						return
					}
					if (this.xfList.length == 0) {
						uni.showToast({
							title: this.app.language.yl_xfss,
							icon: 'none',
						});
						return
					}
					if (this.bahtList.length == 0) {
						uni.showToast({
							title: this.app.language.yl_ibaht,
							icon: 'none',
						});
						return
					}
				}
				if(this.evpeopleList.length>0){
					const submitData = this.evpeopleList.map(item => {
						const {
							areaData,
							...rest
						} = item; // 解构排除 areaData
						return rest; // 返回不包含 areaData 的新对象
					});
					let data1 = [submitData]
					this.form.evpeopleList = data1[0]
				}
				this.form.appToken = this.token
				this.form.phone = this.form.phone1
				if(val==0){
					uni.showLoading({
						title: this.app.language.jzz,
					});
					// 这里可以添加提交表单的逻辑
					Addylcs(this.form).then((res) => {
						if (res.code == 200) {
							uni.hideLoading();
							uni.showToast({
								title: this.app.language.qddsh,
								icon: 'success',
							});
							setTimeout(() => {
								console.log('跳转首页')
								uni.reLaunch({
									url: '/pages/enter/listText'
								});
							}, 1000);
						}
					})
				}else if(val==1||val==2){
					console.log('this.form',this.form)
					uni.showLoading({
						title: this.app.language.jzz,
					});
					xgylcs(this.form).then((res) => {
						if (res.code == 200) {
							uni.hideLoading();
							uni.showToast({
								title: this.app.languageqddsh,
								icon: 'success',
							});
							setTimeout(() => {
								console.log('跳转首页')
								uni.reLaunch({
									url: '/pages/enter/listText'
								});
							}, 1000);
						}
					})
				}
				
			},
		}
	};
</script>
<style>
	.container {
		padding: 10rpx 20rpx;
	}

	.form {
		border: 1px solid #ddd;
		box-shadow: 1px 1px 10rpx #ddd;
		padding: 0 20rpx;
		margin-top: 20rpx;
		position: relative
	}

	.formItem1,
	.formItem {
		margin: 10rpx 0;
		padding: 10rpx;
		/* height: 162rpx; */
		position: relative;
		border-bottom: 1px dashed #ddd
	}

	.formB {
		/* background-color: #f3f3f3; */
		font-size: 24rpx;
		padding: 10rpx;
		margin-top: 10rpx;
		position: absolute;
		right: 10rpx;
		top: -2rpx;
		color: #808080;
		text-align: right;
	}
	
	.formC{
		margin-top: 10rpx;
	}

	.formItem1 text,
	.formItem text {
		font-size: 26rpx;
	}

	.title {
		border-left: 4rpx solid #2f8ef9;
		padding-left: 10rpx;
		margin: 10rpx 0 10rpx 10rpx;
		font-weight: bold;
		font-size: 26rpx;
	}

	.nextStep,
	.previousStep,
	.submitForm {
		background-color: #2f8ef9;
		color: #fff;
		font-size: 26rpx;
		margin-top: 20rpx;
	}

	.bt {
		color: red;
		margin-right: 5rpx;
	}

	.hjbImg button {
		font-size: 22rpx;
		width: 149rpx;
		height: 56rpx;
		background: #2f8ef9;
		color: #fff;
	}

	.hjbImg {
		/* position: absolute;
		bottom: 10rpx; */
		width: 150rpx;
		margin-top: -17rpx;
	}

	.hjbImg1 {
		width: 150rpx;
		margin-top: 20rpx !important;
	}

	.jia {
		border: 1px dashed #2f8ef9;
		text-align: center;
		color: #2f8ef9;
		margin: 20rpx auto 0;
		font-size: 26rpx;
		border-radius: 10rpx;
		padding: 0 0 13rpx;
	}

	.jia image {
		width: 40rpx;
		height: 40rpx;
		position: relative;
		top: 8rpx;
	}

	.del {
		width: 25px;
		height: 25px;
		position: absolute;
		right: -5px;
		top: -8px;
	}

	.radioGroup {
		position: relative;
		top: -18rpx;
	}

	.polSta {
		font-size: 26rpx;
		font-weight: 500;
		/* text-align: right; */
		color: #2f8ef9;
		margin-top: 15rpx;
	}

	.uni-input {
		width: 260rpx;
		color: #808080;
	}

	.radioYes {
		margin-right: 20rpx;
		font-size:24rpx;
	}

	.checkboxYes {
		margin-right: 17rpx;
		color: #808080;
	}

	.picker {
		width: 260rpx;
		color: #808080;
	}

	.scimageBox {
		display: inline-block;
		width: 100%;
		height: 100rpx;
		position: relative;
		/* text-align: center; */
	}

	.scimage {
		width: 121rpx;
		height: 80rpx;
		margin-right: 10rpx;
		margin-top: 5px;
		border-radius: 5rpx;
	}

	.del3 {
		color: red;
		font-size: 26rpx;
		text-align: right;
		width: 50rpx;
		height: 50rpx;
		position: absolute;
		right: 0;
		top: -43rpx;
	}

	.delImg {
		width: 50rpx;
		height: 50rpx;
	}

	.listText {
		font-size: 28rpx;
		color: #2f8ef9;
		margin: 15rpx 0;
		text-align: right;
		font-weight: 500;
		/* border-bottom: 1px solid #ddd; */
		padding-bottom: 10rpx;
	}

	.listText text {
		border: 1px solid #2f8ef9;
		padding: 10rpx 15rpx;
		border-radius: 6rpx;
	}

	.formB checkbox-group {
		position: relative;
		top: -21rpx;
	}

	.popupBox {
		background-color: #fff;
		width: 650rpx;
		padding: 36rpx;
		border-radius: 10rpx;
	}

	.popupItem {
		display: flex;
		padding-bottom: 10rpx;
		border-bottom: 1px solid #ddd;
		margin: 15rpx 0;
	}

	.popupItem button {
		font-size: 24rpx;
		height: 40rpx;
		line-height: 40rpx;
		width: 154rpx;
		background-color: #2f8ef9;
		color: #fff;
	}

	.popupItem text {
		width: 361rpx;
		margin-right: 10rpx;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 1;
		/* 限制显示的行数 */
		overflow: hidden;
	}
	
	/* 在 App.vue 或全局样式文件中 */
	checkbox .wx-checkbox-input,
	checkbox .uni-checkbox-input {
	  width: 16px !important;  /* 宽度 */
	  height: 16px !important; /* 高度 */
	  text-align: center;
	}
	
	/* 对勾图标大小 */
	checkbox .wx-checkbox-input.wx-checkbox-input-checked::before,
	checkbox .uni-checkbox-input.uni-checkbox-input-checked::before {
	  font-size: 12px !important; /* 调整对勾大小 */
	  margin: 0 auto;
	}
	
	radio::before, checkbox::before {
		right: 2px!important;
	}
	
	checkbox-group{
		text-align: right;
		line-height: 28px;
		font-size: 24rpx;
	}
	
	checkbox,radio{
		margin-right: 2px!important;
	}
	
	/* 在 App.vue 或页面样式中 */
	radio .wx-radio-input,
	radio .uni-radio-input {
	  width: 16px !important;   /* 宽度 */
	  height: 16px !important;  /* 高度 */
	}
	
	/* 选中图标大小 */
	radio .wx-radio-input.wx-radio-input-checked::before,
	radio .uni-radio-input.uni-radio-input-checked::before {
	  font-size: 12px !important; /* 调整内部圆点大小 */
	}
</style>